@ckeditor/ckeditor5-markdown-gfm 35.4.0 → 36.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
2
2
  ==========================
3
3
 
4
4
  **CKEditor 5 GitHub Flavored Markdown support** – https://github.com/ckeditor/ckeditor5-markdown-gfm <br>
5
- Copyright (c) 2003-2022, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
5
+ Copyright (c) 2003-2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
6
6
 
7
7
  Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
8
8
 
@@ -1,4 +1,4 @@
1
1
  /*!
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md.
4
4
  */(()=>{var e={704:(e,t,n)=>{e.exports=n(79)("./src/core.js")},492:(e,t,n)=>{e.exports=n(79)("./src/engine.js")},79:e=>{"use strict";e.exports=CKEditor5.dll},915:()=>{}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{Markdown:()=>Ie});var e=n(704),t=n(492);function i(){return{baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let s={baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1};const l=/[&<>"']/,o=/[&<>"']/g,a=/[<>"']|&(?!#?\w+;)/,c=/[<>"']|&(?!#?\w+;)/g,h={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},u=e=>h[e];function p(e,t){if(t){if(l.test(e))return e.replace(o,u)}else if(a.test(e))return e.replace(c,u);return e}const f=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function d(e){return e.replace(f,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const g=/(^|[^\[])\^/g;function k(e,t){e=e.source||e,t=t||"";const n={replace:(t,r)=>(r=(r=r.source||r).replace(g,"$1"),e=e.replace(t,r),n),getRegex:()=>new RegExp(e,t)};return n}const m=/[^\w:]/g,x=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function b(e,t,n){if(e){let e;try{e=decodeURIComponent(d(n)).replace(m,"").toLowerCase()}catch(e){return null}if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}t&&!x.test(n)&&(n=function(e,t){w[" "+e]||(y.test(e)?w[" "+e]=e+"/":w[" "+e]=R(e,"/",!0));e=w[" "+e];const n=-1===e.indexOf(":");return"//"===t.substring(0,2)?n?t:e.replace(_,"$1")+t:"/"===t.charAt(0)?n?t:e.replace(v,"$1")+t:e+t}(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(e){return null}return n}const w={},y=/^[^:]+:\/*[^/]*$/,_=/^([^:]+:)[\s\S]*$/,v=/^([^:]+:\/*[^/]*)[\s\S]*$/;const z={exec:function(){}};function S(e){let t,n,r=1;for(;r<arguments.length;r++)for(n in t=arguments[r],t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function $(e,t){const n=e.replace(/\|/g,((e,t,n)=>{let r=!1,i=t;for(;--i>=0&&"\\"===n[i];)r=!r;return r?"|":" |"})).split(/ \|/);let r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(/\\\|/g,"|");return n}function R(e,t,n){const r=e.length;if(0===r)return"";let i=0;for(;i<r;){const s=e.charAt(r-i-1);if(s!==t||n){if(s===t||!n)break;i++}else i++}return e.substr(0,r-i)}function T(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function A(e,t){if(t<1)return"";let n="";for(;t>1;)1&t&&(n+=e),t>>=1,e+=e;return n+e}function N(e,t,n,r){const i=t.href,s=t.title?p(t.title):null,l=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){r.state.inLink=!0;const e={type:"link",raw:n,href:i,title:s,text:l,tokens:r.inlineTokens(l,[])};return r.state.inLink=!1,e}return{type:"image",raw:n,href:i,title:s,text:p(l)}}class C{constructor(e){this.options=e||s}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:R(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const r=n[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=r.length?e.slice(r.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim():t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=R(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}const n={type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:[]};return this.lexer.inline(n.text,n.tokens),n}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const e=t[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:t[0],tokens:this.lexer.blockTokens(e,[]),text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n,r,i,s,l,o,a,c,h,u,p,f,d=t[1].trim();const g=d.length>1,k={type:"list",raw:"",ordered:g,start:g?+d.slice(0,-1):"",loose:!1,items:[]};d=g?`\\d{1,9}\\${d.slice(-1)}`:`\\${d}`,this.options.pedantic&&(d=g?d:"[*+-]");const m=new RegExp(`^( {0,3}${d})((?: [^\\n]*)?(?:\\n|$))`);for(;e&&(f=!1,t=m.exec(e))&&!this.rules.block.hr.test(e);){if(n=t[0],e=e.substring(n.length),c=t[2].split("\n",1)[0],h=e.split("\n",1)[0],this.options.pedantic?(s=2,p=c.trimLeft()):(s=t[2].search(/[^ ]/),s=s>4?1:s,p=c.slice(s),s+=t[1].length),o=!1,!c&&/^ *$/.test(h)&&(n+=h+"\n",e=e.substring(h.length+1),f=!0),!f){const t=new RegExp(`^ {0,${Math.min(3,s-1)}}(?:[*+-]|\\d{1,9}[.)])`);for(;e&&(u=e.split("\n",1)[0],c=u,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!t.test(c));){if(c.search(/[^ ]/)>=s||!c.trim())p+="\n"+c.slice(s);else{if(o)break;p+="\n"+c}o||c.trim()||(o=!0),n+=u+"\n",e=e.substring(u.length+1)}}k.loose||(a?k.loose=!0:/\n *\n *$/.test(n)&&(a=!0)),this.options.gfm&&(r=/^\[[ xX]\] /.exec(p),r&&(i="[ ] "!==r[0],p=p.replace(/^\[[ xX]\] +/,""))),k.items.push({type:"list_item",raw:n,task:!!r,checked:i,loose:!1,text:p}),k.raw+=n}k.items[k.items.length-1].raw=n.trimRight(),k.items[k.items.length-1].text=p.trimRight(),k.raw=k.raw.trimRight();const x=k.items.length;for(l=0;l<x;l++){this.lexer.state.top=!1,k.items[l].tokens=this.lexer.blockTokens(k.items[l].text,[]);const e=k.items[l].tokens.filter((e=>"space"===e.type)),t=e.every((e=>{const t=e.raw.split("");let n=0;for(const e of t)if("\n"===e&&(n+=1),n>1)return!0;return!1}));!k.loose&&e.length&&t&&(k.loose=!0,k.items[l].loose=!0)}return k}}html(e){const t=this.rules.block.html.exec(e);if(t){const e={type:"html",raw:t[0],pre:!this.options.sanitizer&&("pre"===t[1]||"script"===t[1]||"style"===t[1]),text:t[0]};return this.options.sanitize&&(e.type="paragraph",e.text=this.options.sanitizer?this.options.sanitizer(t[0]):p(t[0]),e.tokens=[],this.lexer.inline(e.text,e.tokens)),e}}def(e){const t=this.rules.block.def.exec(e);if(t){t[3]&&(t[3]=t[3].substring(1,t[3].length-1));return{type:"def",tag:t[1].toLowerCase().replace(/\s+/g," "),raw:t[0],href:t[2],title:t[3]}}}table(e){const t=this.rules.block.table.exec(e);if(t){const e={type:"table",header:$(t[1]).map((e=>({text:e}))),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[]};if(e.header.length===e.align.length){e.raw=t[0];let n,r,i,s,l=e.align.length;for(n=0;n<l;n++)/^ *-+: *$/.test(e.align[n])?e.align[n]="right":/^ *:-+: *$/.test(e.align[n])?e.align[n]="center":/^ *:-+ *$/.test(e.align[n])?e.align[n]="left":e.align[n]=null;for(l=e.rows.length,n=0;n<l;n++)e.rows[n]=$(e.rows[n],e.header.length).map((e=>({text:e})));for(l=e.header.length,r=0;r<l;r++)e.header[r].tokens=[],this.lexer.inlineTokens(e.header[r].text,e.header[r].tokens);for(l=e.rows.length,r=0;r<l;r++)for(s=e.rows[r],i=0;i<s.length;i++)s[i].tokens=[],this.lexer.inlineTokens(s[i].text,s[i].tokens);return e}}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t){const e={type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:[]};return this.lexer.inline(e.text,e.tokens),e}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e={type:"paragraph",raw:t[0],text:"\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1],tokens:[]};return this.lexer.inline(e.text,e.tokens),e}}text(e){const t=this.rules.block.text.exec(e);if(t){const e={type:"text",raw:t[0],text:t[0],tokens:[]};return this.lexer.inline(e.text,e.tokens),e}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:p(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):p(t[0]):t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=R(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;const n=e.length;let r=0,i=0;for(;i<n;i++)if("\\"===e[i])i++;else if(e[i]===t[0])r++;else if(e[i]===t[1]&&(r--,r<0))return i;return-1}(t[2],"()");if(e>-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^</.test(n)&&(n=this.options.pedantic&&!/>$/.test(e)?n.slice(1):n.slice(1,-1)),N(t,{href:n?n.replace(this.rules.inline._escapes,"$1"):n,title:r?r.replace(this.rules.inline._escapes,"$1"):r},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=(n[2]||n[1]).replace(/\s+/g," ");if(e=t[e.toLowerCase()],!e||!e.href){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return N(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrong.lDelim.exec(e);if(!r)return;if(r[3]&&n.match(/[\p{L}\p{N}]/u))return;const i=r[1]||r[2]||"";if(!i||i&&(""===n||this.rules.inline.punctuation.exec(n))){const n=r[0].length-1;let i,s,l=n,o=0;const a="*"===r[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(a.lastIndex=0,t=t.slice(-1*e.length+n);null!=(r=a.exec(t));){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(s=i.length,r[3]||r[4]){l+=s;continue}if((r[5]||r[6])&&n%3&&!((n+s)%3)){o+=s;continue}if(l-=s,l>0)continue;if(s=Math.min(s,s+l+o),Math.min(n,s)%2){const t=e.slice(1,n+r.index+s);return{type:"em",raw:e.slice(0,n+r.index+s+1),text:t,tokens:this.lexer.inlineTokens(t,[])}}const t=e.slice(2,n+r.index+s-1);return{type:"strong",raw:e.slice(0,n+r.index+s+1),text:t,tokens:this.lexer.inlineTokens(t,[])}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return n&&r&&(e=e.substring(1,e.length-1)),e=p(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2],[])}}autolink(e,t){const n=this.rules.inline.autolink.exec(e);if(n){let e,r;return"@"===n[2]?(e=p(this.options.mangle?t(n[1]):n[1]),r="mailto:"+e):(e=p(n[1]),r=e),{type:"link",raw:n[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}url(e,t){let n;if(n=this.rules.inline.url.exec(e)){let e,r;if("@"===n[2])e=p(this.options.mangle?t(n[0]):n[0]),r="mailto:"+e;else{let t;do{t=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0]}while(t!==n[0]);e=p(n[0]),r="www."===n[1]?"http://"+e:e}return{type:"link",raw:n[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e,t){const n=this.rules.inline.text.exec(e);if(n){let e;return e=this.lexer.state.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):p(n[0]):n[0]:p(this.options.smartypants?t(n[0]):n[0]),{type:"text",raw:n[0],text:e}}}}const I={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?<?([^\s>]+)>?(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:z,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\.|[^\[\]\\])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};I.def=k(I.def).replace("label",I._label).replace("title",I._title).getRegex(),I.bullet=/(?:[*+-]|\d{1,9}[.)])/,I.listItemStart=k(/^( *)(bull) */).replace("bull",I.bullet).getRegex(),I.list=k(I.list).replace(/bull/g,I.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+I.def.source+")").getRegex(),I._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",I._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,I.html=k(I.html,"i").replace("comment",I._comment).replace("tag",I._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),I.paragraph=k(I._paragraph).replace("hr",I.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",I._tag).getRegex(),I.blockquote=k(I.blockquote).replace("paragraph",I.paragraph).getRegex(),I.normal=S({},I),I.gfm=S({},I.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),I.gfm.table=k(I.gfm.table).replace("hr",I.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",I._tag).getRegex(),I.gfm.paragraph=k(I._paragraph).replace("hr",I.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",I.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",I._tag).getRegex(),I.pedantic=S({},I.normal,{html:k("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",I._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:z,paragraph:k(I.normal._paragraph).replace("hr",I.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",I.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const E={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:z,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:z,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};function O(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function D(e){let t,n,r="";const i=e.length;for(t=0;t<i;t++)n=e.charCodeAt(t),Math.random()>.5&&(n="x"+n.toString(16)),r+="&#"+n+";";return r}E._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",E.punctuation=k(E.punctuation).replace(/punctuation/g,E._punctuation).getRegex(),E.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,E.escapedEmSt=/\\\*|\\_/g,E._comment=k(I._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),E.emStrong.lDelim=k(E.emStrong.lDelim).replace(/punct/g,E._punctuation).getRegex(),E.emStrong.rDelimAst=k(E.emStrong.rDelimAst,"g").replace(/punct/g,E._punctuation).getRegex(),E.emStrong.rDelimUnd=k(E.emStrong.rDelimUnd,"g").replace(/punct/g,E._punctuation).getRegex(),E._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,E._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,E._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,E.autolink=k(E.autolink).replace("scheme",E._scheme).replace("email",E._email).getRegex(),E._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,E.tag=k(E.tag).replace("comment",E._comment).replace("attribute",E._attribute).getRegex(),E._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,E._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,E._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,E.link=k(E.link).replace("label",E._label).replace("href",E._href).replace("title",E._title).getRegex(),E.reflink=k(E.reflink).replace("label",E._label).replace("ref",I._label).getRegex(),E.nolink=k(E.nolink).replace("ref",I._label).getRegex(),E.reflinkSearch=k(E.reflinkSearch,"g").replace("reflink",E.reflink).replace("nolink",E.nolink).getRegex(),E.normal=S({},E),E.pedantic=S({},E.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:k(/^!?\[(label)\]\((.*?)\)/).replace("label",E._label).getRegex(),reflink:k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",E._label).getRegex()}),E.gfm=S({},E.normal,{escape:k(E.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),E.gfm.url=k(E.gfm.url,"i").replace("email",E.gfm._extended_email).getRegex(),E.breaks=S({},E.gfm,{br:k(E.br).replace("{2,}","*").getRegex(),text:k(E.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});class L{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||s,this.options.tokenizer=this.options.tokenizer||new C,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:I.normal,inline:E.normal};this.options.pedantic?(t.block=I.pedantic,t.inline=E.pedantic):this.options.gfm&&(t.block=I.gfm,this.options.breaks?t.inline=E.breaks:t.inline=E.gfm),this.tokenizer.rules=t}static get rules(){return{block:I,inline:E}}static lex(e,t){return new L(t).lex(e)}static lexInline(e,t){return new L(t).inlineTokens(e)}lex(e){let t;for(e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(e,this.tokens);t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){let n,r,i,s;for(this.options.pedantic&&(e=e.replace(/^ +$/gm,""));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),r=t[t.length-1],!r||"paragraph"!==r.type&&"text"!==r.type?t.push(n):(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=r.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),r=t[t.length-1],!r||"paragraph"!==r.type&&"text"!==r.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(r.raw+="\n"+n.raw,r.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=r.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(i=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startBlock.forEach((function(e){r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))})),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i)))r=t[t.length-1],s&&"paragraph"===r.type?(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n),s=i.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===r.type?(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t){this.inlineQueue.push({src:e,tokens:t})}inlineTokens(e,t=[]){let n,r,i,s,l,o,a=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(a));)e.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,s.index)+"["+A("a",s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(a));)a=a.slice(0,s.index)+"["+A("a",s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(s=this.tokenizer.rules.inline.escapedEmSt.exec(a));)a=a.slice(0,s.index)+"++"+a.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);for(;e;)if(l||(o=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===n.type&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===n.type&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,a,o))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e,D))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e,D))){if(i=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startInline.forEach((function(e){r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))})),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(i,O))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),l=!0,r=t[t.length-1],r&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class B{constructor(e){this.options=e||s}code(e,t,n){const r=(t||"").match(/\S*/)[0];if(this.options.highlight){const t=this.options.highlight(e,r);null!=t&&t!==e&&(n=!0,e=t)}return e=e.replace(/\n$/,"")+"\n",r?'<pre><code class="'+this.options.langPrefix+p(r,!0)+'">'+(n?e:p(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:p(e,!0))+"</code></pre>\n"}blockquote(e){return"<blockquote>\n"+e+"</blockquote>\n"}html(e){return e}heading(e,t,n,r){return this.options.headerIds?"<h"+t+' id="'+this.options.headerPrefix+r.slug(n)+'">'+e+"</h"+t+">\n":"<h"+t+">"+e+"</h"+t+">\n"}hr(){return this.options.xhtml?"<hr/>\n":"<hr>\n"}list(e,t,n){const r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+r+">\n"}listitem(e){return"<li>"+e+"</li>\n"}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "}paragraph(e){return"<p>"+e+"</p>\n"}table(e,t){return t&&(t="<tbody>"+t+"</tbody>"),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"}tablerow(e){return"<tr>\n"+e+"</tr>\n"}tablecell(e,t){const n=t.header?"th":"td";return(t.align?"<"+n+' align="'+t.align+'">':"<"+n+">")+e+"</"+n+">\n"}strong(e){return"<strong>"+e+"</strong>"}em(e){return"<em>"+e+"</em>"}codespan(e){return"<code>"+e+"</code>"}br(){return this.options.xhtml?"<br/>":"<br>"}del(e){return"<del>"+e+"</del>"}link(e,t,n){if(null===(e=b(this.options.sanitize,this.options.baseUrl,e)))return n;let r='<a href="'+p(e)+'"';return t&&(r+=' title="'+t+'"'),r+=">"+n+"</a>",r}image(e,t,n){if(null===(e=b(this.options.sanitize,this.options.baseUrl,e)))return n;let r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">",r}text(e){return e}}class P{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class q{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let n=e,r=0;if(this.seen.hasOwnProperty(n)){r=this.seen[e];do{r++,n=e+"-"+r}while(this.seen.hasOwnProperty(n))}return t||(this.seen[e]=r,this.seen[n]=0),n}slug(e,t={}){const n=this.serialize(e);return this.getNextSafeSlug(n,t.dryrun)}}class Z{constructor(e){this.options=e||s,this.options.renderer=this.options.renderer||new B,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new P,this.slugger=new q}static parse(e,t){return new Z(t).parse(e)}static parseInline(e,t){return new Z(t).parseInline(e)}parse(e,t=!0){let n,r,i,s,l,o,a,c,h,u,p,f,g,k,m,x,b,w,y,_="";const v=e.length;for(n=0;n<v;n++)if(u=e[n],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[u.type]&&(y=this.options.extensions.renderers[u.type].call({parser:this},u),!1!==y||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(u.type)))_+=y||"";else switch(u.type){case"space":continue;case"hr":_+=this.renderer.hr();continue;case"heading":_+=this.renderer.heading(this.parseInline(u.tokens),u.depth,d(this.parseInline(u.tokens,this.textRenderer)),this.slugger);continue;case"code":_+=this.renderer.code(u.text,u.lang,u.escaped);continue;case"table":for(c="",a="",s=u.header.length,r=0;r<s;r++)a+=this.renderer.tablecell(this.parseInline(u.header[r].tokens),{header:!0,align:u.align[r]});for(c+=this.renderer.tablerow(a),h="",s=u.rows.length,r=0;r<s;r++){for(o=u.rows[r],a="",l=o.length,i=0;i<l;i++)a+=this.renderer.tablecell(this.parseInline(o[i].tokens),{header:!1,align:u.align[i]});h+=this.renderer.tablerow(a)}_+=this.renderer.table(c,h);continue;case"blockquote":h=this.parse(u.tokens),_+=this.renderer.blockquote(h);continue;case"list":for(p=u.ordered,f=u.start,g=u.loose,s=u.items.length,h="",r=0;r<s;r++)m=u.items[r],x=m.checked,b=m.task,k="",m.task&&(w=this.renderer.checkbox(x),g?m.tokens.length>0&&"paragraph"===m.tokens[0].type?(m.tokens[0].text=w+" "+m.tokens[0].text,m.tokens[0].tokens&&m.tokens[0].tokens.length>0&&"text"===m.tokens[0].tokens[0].type&&(m.tokens[0].tokens[0].text=w+" "+m.tokens[0].tokens[0].text)):m.tokens.unshift({type:"text",text:w}):k+=w),k+=this.parse(m.tokens,g),h+=this.renderer.listitem(k,b,x);_+=this.renderer.list(h,p,f);continue;case"html":_+=this.renderer.html(u.text);continue;case"paragraph":_+=this.renderer.paragraph(this.parseInline(u.tokens));continue;case"text":for(h=u.tokens?this.parseInline(u.tokens):u.text;n+1<v&&"text"===e[n+1].type;)u=e[++n],h+="\n"+(u.tokens?this.parseInline(u.tokens):u.text);_+=t?this.renderer.paragraph(h):h;continue;default:{const e='Token with "'+u.type+'" type was not found.';if(this.options.silent)return void console.error(e);throw new Error(e)}}return _}parseInline(e,t){t=t||this.renderer;let n,r,i,s="";const l=e.length;for(n=0;n<l;n++)if(r=e[n],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]&&(i=this.options.extensions.renderers[r.type].call({parser:this},r),!1!==i||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)))s+=i||"";else switch(r.type){case"escape":case"text":s+=t.text(r.text);break;case"html":s+=t.html(r.text);break;case"link":s+=t.link(r.href,r.title,this.parseInline(r.tokens,t));break;case"image":s+=t.image(r.href,r.title,r.text);break;case"strong":s+=t.strong(this.parseInline(r.tokens,t));break;case"em":s+=t.em(this.parseInline(r.tokens,t));break;case"codespan":s+=t.codespan(r.text);break;case"br":s+=t.br();break;case"del":s+=t.del(this.parseInline(r.tokens,t));break;default:{const e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return void console.error(e);throw new Error(e)}}return s}}function j(e,t,n){if(null==e)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");if("function"==typeof t&&(n=t,t=null),T(t=S({},j.defaults,t||{})),n){const r=t.highlight;let i;try{i=L.lex(e,t)}catch(e){return n(e)}const s=function(e){let s;if(!e)try{t.walkTokens&&j.walkTokens(i,t.walkTokens),s=Z.parse(i,t)}catch(t){e=t}return t.highlight=r,e?n(e):n(null,s)};if(!r||r.length<3)return s();if(delete t.highlight,!i.length)return s();let l=0;return j.walkTokens(i,(function(e){"code"===e.type&&(l++,setTimeout((()=>{r(e.text,e.lang,(function(t,n){if(t)return s(t);null!=n&&n!==e.text&&(e.text=n,e.escaped=!0),l--,0===l&&s()}))}),0))})),void(0===l&&s())}try{const n=L.lex(e,t);return t.walkTokens&&j.walkTokens(n,t.walkTokens),Z.parse(n,t)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+p(e.message+"",!0)+"</pre>";throw e}}j.options=j.setOptions=function(e){var t;return S(j.defaults,e),t=j.defaults,s=t,j},j.getDefaults=i,j.defaults=s,j.use=function(...e){const t=S({},...e),n=j.defaults.extensions||{renderers:{},childTokens:{}};let r;e.forEach((e=>{if(e.extensions&&(r=!0,e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if(e.renderer){const t=n.renderers?n.renderers[e.name]:null;n.renderers[e.name]=t?function(...n){let r=e.renderer.apply(this,n);return!1===r&&(r=t.apply(this,n)),r}:e.renderer}if(e.tokenizer){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");n[e.level]?n[e.level].unshift(e.tokenizer):n[e.level]=[e.tokenizer],e.start&&("block"===e.level?n.startBlock?n.startBlock.push(e.start):n.startBlock=[e.start]:"inline"===e.level&&(n.startInline?n.startInline.push(e.start):n.startInline=[e.start]))}e.childTokens&&(n.childTokens[e.name]=e.childTokens)}))),e.renderer){const n=j.defaults.renderer||new B;for(const t in e.renderer){const r=n[t];n[t]=(...i)=>{let s=e.renderer[t].apply(n,i);return!1===s&&(s=r.apply(n,i)),s}}t.renderer=n}if(e.tokenizer){const n=j.defaults.tokenizer||new C;for(const t in e.tokenizer){const r=n[t];n[t]=(...i)=>{let s=e.tokenizer[t].apply(n,i);return!1===s&&(s=r.apply(n,i)),s}}t.tokenizer=n}if(e.walkTokens){const n=j.defaults.walkTokens;t.walkTokens=function(t){e.walkTokens.call(this,t),n&&n.call(this,t)}}r&&(t.extensions=n),j.setOptions(t)}))},j.walkTokens=function(e,t){for(const n of e)switch(t.call(j,n),n.type){case"table":for(const e of n.header)j.walkTokens(e.tokens,t);for(const e of n.rows)for(const n of e)j.walkTokens(n.tokens,t);break;case"list":j.walkTokens(n.items,t);break;default:j.defaults.extensions&&j.defaults.extensions.childTokens&&j.defaults.extensions.childTokens[n.type]?j.defaults.extensions.childTokens[n.type].forEach((function(e){j.walkTokens(n[e],t)})):n.tokens&&j.walkTokens(n.tokens,t)}},j.parseInline=function(e,t){if(null==e)throw new Error("marked.parseInline(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");T(t=S({},j.defaults,t||{}));try{const n=L.lexInline(e,t);return t.walkTokens&&j.walkTokens(n,t.walkTokens),Z.parseInline(n,t)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+p(e.message+"",!0)+"</pre>";throw e}},j.Parser=Z,j.parser=Z.parse,j.Renderer=B,j.TextRenderer=P,j.Lexer=L,j.lexer=L.lex,j.Tokenizer=C,j.Slugger=q,j.parse=j;j.options,j.setOptions,j.use,j.walkTokens,j.parseInline,Z.parse,L.lex;function M(e,t){return Array(t+1).join(e)}j.use({tokenizer:{autolink:()=>null,url:()=>null},renderer:{checkbox(...e){return Object.getPrototypeOf(this).checkbox.call(this,...e).trimRight()},code(...e){return Object.getPrototypeOf(this).code.call(this,...e).replace("\n</code>","</code>")}}});var U=["address","article","aside","audio","blockquote","body","canvas","center","dd","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frameset","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","isindex","li","main","menu","nav","noframes","noscript","ol","output","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"];function Q(e){return-1!==U.indexOf(e.nodeName.toLowerCase())}var F=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];function V(e){return-1!==F.indexOf(e.nodeName.toLowerCase())}var H=F.join();var K={};function G(e){for(var t in this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[],e.rules)this.array.push(e.rules[t])}function W(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(X(i,t,n))return i}}function X(e,t,n){var r=e.filter;if("string"==typeof r){if(r===t.nodeName.toLowerCase())return!0}else if(Array.isArray(r)){if(r.indexOf(t.nodeName.toLowerCase())>-1)return!0}else{if("function"!=typeof r)throw new TypeError("`filter` needs to be a string, array, or function");if(r.call(e,t,n))return!0}}function J(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function Y(e,t,n){return e&&e.parentNode===t||n(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}K.paragraph={filter:"p",replacement:function(e){return"\n\n"+e+"\n\n"}},K.lineBreak={filter:"br",replacement:function(e,t,n){return n.br+"\n"}},K.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,t,n){var r=Number(t.nodeName.charAt(1));return"setext"===n.headingStyle&&r<3?"\n\n"+e+"\n"+M(1===r?"=":"-",e.length)+"\n\n":"\n\n"+M("#",r)+" "+e+"\n\n"}},K.blockquote={filter:"blockquote",replacement:function(e){return"\n\n"+(e=(e=e.replace(/^\n+|\n+$/g,"")).replace(/^/gm,"> "))+"\n\n"}},K.list={filter:["ul","ol"],replacement:function(e,t){var n=t.parentNode;return"LI"===n.nodeName&&n.lastElementChild===t?"\n"+e:"\n\n"+e+"\n\n"}},K.listItem={filter:"li",replacement:function(e,t,n){e=e.replace(/^\n+/,"").replace(/\n+$/,"\n").replace(/\n/gm,"\n ");var r=n.bulletListMarker+" ",i=t.parentNode;if("OL"===i.nodeName){var s=i.getAttribute("start"),l=Array.prototype.indexOf.call(i.children,t);r=(s?Number(s)+l:l+1)+". "}return r+e+(t.nextSibling&&!/\n$/.test(e)?"\n":"")}},K.indentedCodeBlock={filter:function(e,t){return"indented"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,n){return"\n\n "+t.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},K.fencedCodeBlock={filter:function(e,t){return"fenced"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,n){for(var r,i=((t.firstChild.className||"").match(/language-(\S+)/)||[null,""])[1],s=t.firstChild.textContent,l=n.fence.charAt(0),o=3,a=new RegExp("^"+l+"{3,}","gm");r=a.exec(s);)r[0].length>=o&&(o=r[0].length+1);var c=M(l,o);return"\n\n"+c+i+"\n"+s.replace(/\n$/,"")+"\n"+c+"\n\n"}},K.horizontalRule={filter:"hr",replacement:function(e,t,n){return"\n\n"+n.hr+"\n\n"}},K.inlineLink={filter:function(e,t){return"inlined"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t){return"["+e+"]("+t.getAttribute("href")+(t.title?' "'+t.title+'"':"")+")"}},K.referenceLink={filter:function(e,t){return"referenced"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t,n){var r,i,s=t.getAttribute("href"),l=t.title?' "'+t.title+'"':"";switch(n.linkReferenceStyle){case"collapsed":r="["+e+"][]",i="["+e+"]: "+s+l;break;case"shortcut":r="["+e+"]",i="["+e+"]: "+s+l;break;default:var o=this.references.length+1;r="["+e+"]["+o+"]",i="["+o+"]: "+s+l}return this.references.push(i),r},references:[],append:function(e){var t="";return this.references.length&&(t="\n\n"+this.references.join("\n")+"\n\n",this.references=[]),t}},K.emphasis={filter:["em","i"],replacement:function(e,t,n){return e.trim()?n.emDelimiter+e+n.emDelimiter:""}},K.strong={filter:["strong","b"],replacement:function(e,t,n){return e.trim()?n.strongDelimiter+e+n.strongDelimiter:""}},K.code={filter:function(e){var t=e.previousSibling||e.nextSibling,n="PRE"===e.parentNode.nodeName&&!t;return"CODE"===e.nodeName&&!n},replacement:function(e){if(!e.trim())return"";var t="`",n="",r="",i=e.match(/`+/gm);if(i)for(/^`/.test(e)&&(n=" "),/`$/.test(e)&&(r=" ");-1!==i.indexOf(t);)t+="`";return t+n+e+r+t}},K.image={filter:"img",replacement:function(e,t){var n=t.alt||"",r=t.getAttribute("src")||"",i=t.title||"";return r?"!["+n+"]("+r+(i?' "'+i+'"':"")+")":""}},G.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return""}})},forNode:function(e){return e.isBlank?this.blankRule:(t=W(this.array,e,this.options))||(t=W(this._keep,e,this.options))||(t=W(this._remove,e,this.options))?t:this.defaultRule;var t},forEach:function(e){for(var t=0;t<this.array.length;t++)e(this.array[t],t)}};var ee="undefined"!=typeof window?window:{};var te,ne=function(){var e=ee.DOMParser,t=!1;try{(new e).parseFromString("","text/html")&&(t=!0)}catch(e){}return t}()?ee.DOMParser:function(){var e=function(){},t=n(915).JSDOM;return e.prototype.parseFromString=function(e){return new t(e).window.document},e}();function re(e){var t;"string"==typeof e?t=(te=te||new ne).parseFromString('<x-turndown id="turndown-root">'+e+"</x-turndown>","text/html").getElementById("turndown-root"):t=e.cloneNode(!0);return function(e){var t=e.element,n=e.isBlock,r=e.isVoid,i=e.isPre||function(e){return"PRE"===e.nodeName};if(t.firstChild&&!i(t)){for(var s=null,l=!1,o=null,a=Y(o,t,i);a!==t;){if(3===a.nodeType||4===a.nodeType){var c=a.data.replace(/[ \r\n\t]+/g," ");if(s&&!/ $/.test(s.data)||l||" "!==c[0]||(c=c.substr(1)),!c){a=J(a);continue}a.data=c,s=a}else{if(1!==a.nodeType){a=J(a);continue}n(a)||"BR"===a.nodeName?(s&&(s.data=s.data.replace(/ $/,"")),s=null,l=!1):r(a)&&(s=null,l=!0)}var h=Y(o,a,i);o=a,a=h}s&&(s.data=s.data.replace(/ $/,""),s.data||J(s))}}({element:t,isBlock:Q,isVoid:V}),t}function ie(e){return e.isBlock=Q(e),e.isCode="code"===e.nodeName.toLowerCase()||e.parentNode.isCode,e.isBlank=function(e){return-1===["A","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"].indexOf(e.nodeName)&&/^\s*$/i.test(e.textContent)&&!V(e)&&!function(e){return e.querySelector&&e.querySelector(H)}(e)}(e),e.flankingWhitespace=function(e){var t="",n="";if(!e.isBlock){var r=/^\s/.test(e.textContent),i=/\s$/.test(e.textContent),s=e.isBlank&&r&&i;r&&!se("left",e)&&(t=" "),s||!i||se("right",e)||(n=" ")}return{leading:t,trailing:n}}(e),e}function se(e,t){var n,r,i;return"left"===e?(n=t.previousSibling,r=/ $/):(n=t.nextSibling,r=/^ /),n&&(3===n.nodeType?i=r.test(n.nodeValue):1!==n.nodeType||Q(n)||(i=r.test(n.textContent))),i}var le=Array.prototype.reduce,oe=/^\n*/,ae=/\n*$/,ce=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function he(e){if(!(this instanceof he))return new he(e);var t={rules:K,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",blankReplacement:function(e,t){return t.isBlock?"\n\n":""},keepReplacement:function(e,t){return t.isBlock?"\n\n"+t.outerHTML+"\n\n":t.outerHTML},defaultReplacement:function(e,t){return t.isBlock?"\n\n"+e+"\n\n":e}};this.options=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}({},t,e),this.rules=new G(this.options)}function ue(e){var t=this;return le.call(e.childNodes,(function(e,n){var r="";return 3===(n=new ie(n)).nodeType?r=n.isCode?n.nodeValue:t.escape(n.nodeValue):1===n.nodeType&&(r=fe.call(t,n)),de(e,r)}),"")}function pe(e){var t=this;return this.rules.forEach((function(n){"function"==typeof n.append&&(e=de(e,n.append(t.options)))})),e.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function fe(e){var t=this.rules.forNode(e),n=ue.call(this,e),r=e.flankingWhitespace;return(r.leading||r.trailing)&&(n=n.trim()),r.leading+t.replacement(n,e,this.options)+r.trailing}function de(e,t){var n,r,i,s=(n=t,r=[e.match(ae)[0],n.match(oe)[0]].sort(),(i=r[r.length-1]).length<2?i:"\n\n");return(e=e.replace(ae,""))+s+(t=t.replace(oe,""))}he.prototype={turndown:function(e){if(!function(e){return null!=e&&("string"==typeof e||e.nodeType&&(1===e.nodeType||9===e.nodeType||11===e.nodeType))}(e))throw new TypeError(e+" is not a string, or an element/document/fragment node.");if(""===e)return"";var t=ue.call(this,new re(e));return pe.call(this,t)},use:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.use(e[t]);else{if("function"!=typeof e)throw new TypeError("plugin must be a Function or an Array of Functions");e(this)}return this},addRule:function(e,t){return this.rules.add(e,t),this},keep:function(e){return this.rules.keep(e),this},remove:function(e){return this.rules.remove(e),this},escape:function(e){return ce.reduce((function(e,t){return e.replace(t[0],t[1])}),e)}};const ge=he;var ke=/highlight-(?:text|source)-([a-z0-9]+)/;function me(e){e.addRule("highlightedCodeBlock",{filter:function(e){var t=e.firstChild;return"DIV"===e.nodeName&&ke.test(e.className)&&t&&"PRE"===t.nodeName},replacement:function(e,t,n){var r=((t.className||"").match(ke)||[null,""])[1];return"\n\n"+n.fence+r+"\n"+t.firstChild.textContent+"\n"+n.fence+"\n\n"}})}function xe(e){e.addRule("strikethrough",{filter:["del","s","strike"],replacement:function(e){return"~"+e+"~"}})}var be=Array.prototype.indexOf,we=Array.prototype.every,ye={};function _e(e){var t,n,r=e.parentNode;return"THEAD"===r.nodeName||r.firstChild===e&&("TABLE"===r.nodeName||(n=(t=r).previousSibling,"TBODY"===t.nodeName&&(!n||"THEAD"===n.nodeName&&/^\s*$/i.test(n.textContent))))&&we.call(e.childNodes,(function(e){return"TH"===e.nodeName}))}function ve(e,t){var n=" ";return 0===be.call(t.parentNode.childNodes,t)&&(n="| "),n+e+" |"}function ze(e){for(var t in e.keep((function(e){return"TABLE"===e.nodeName&&!_e(e.rows[0])})),ye)e.addRule(t,ye[t])}function Se(e){e.addRule("taskListItems",{filter:function(e){return"checkbox"===e.type&&"LI"===e.parentNode.nodeName},replacement:function(e,t){return(t.checked?"[x]":"[ ]")+" "}})}ye.tableCell={filter:["th","td"],replacement:function(e,t){return ve(e,t)}},ye.tableRow={filter:"tr",replacement:function(e,t){var n="",r={left:":--",right:"--:",center:":-:"};if(_e(t))for(var i=0;i<t.childNodes.length;i++){var s="---",l=(t.childNodes[i].getAttribute("align")||"").toLowerCase();l&&(s=r[l]||s),n+=ve(s,t.childNodes[i])}return"\n"+e+(n?"\n"+n:"")}},ye.table={filter:function(e){return"TABLE"===e.nodeName&&_e(e.rows[0])},replacement:function(e){return"\n\n"+(e=e.replace("\n\n","\n"))+"\n\n"}},ye.tableSection={filter:["thead","tbody","tfoot"],replacement:function(e){return e}};const $e=ge.prototype.escape;function Re(e){return e=(e=$e(e)).replace(/</g,"\\<")}ge.prototype.escape=function(e){let t="",n=0;for(const r of function*(e){for(const t of e.matchAll(Ae)){const e=t[0],n=Ne(e);yield Object.assign([e.substring(0,n)],{index:t.index})}}(e)){const i=r.index;i>n&&(t+=Re(e.substring(n,i)));const s=r[0];t+=s,n=i+s.length}return n<e.length&&(t+=Re(e.substring(n,e.length))),t};const Te=new ge({codeBlockStyle:"fenced",hr:"---",headingStyle:"atx"});Te.use([function(e){e.use([me,xe,ze,Se])},function(e){e.addRule("taskListItems",{filter:e=>"checkbox"===e.type&&("LI"===e.parentNode.nodeName||"LI"===e.parentNode.parentNode.nodeName),replacement:(e,t)=>(t.checked?"[x]":"[ ]")+" "})}]);const Ae=new RegExp(/\b(?:(?:https?|ftp):\/\/|www\.)/.source+/(?![-_])(?:[-_a-z0-9\u00a1-\uffff]{1,63}\.)+(?:[a-z\u00a1-\uffff]{2,63})/.source+/(?:[^\s<>]*)/.source,"gi");function Ne(e){let t=e.length;for(;t>0;){const n=e[t-1];if("?!.,:*_~'\"".includes(n))t--;else{if(")"!=n)break;{let n=0;for(let r=0;r<t;r++)"("==e[r]?n++:")"==e[r]&&n--;if(!(n<0))break;t--}}}return t}class Ce{constructor(e){this._htmlDP=new t.HtmlDataProcessor(e)}keepHtml(e){Te.keep([e])}toView(e){const t=(n=e,j.parse(n,{gfm:!0,breaks:!0,tables:!0,xhtml:!0,headerIds:!1}));var n;return this._htmlDP.toView(t)}toData(e){return function(e){return Te.turndown(e)}(this._htmlDP.toData(e))}registerRawContentMatcher(e){this._htmlDP.registerRawContentMatcher(e)}useFillerType(){}}class Ie extends e.Plugin{constructor(e){super(e),e.data.processor=new Ce(e.data.viewDocument)}static get pluginName(){return"Markdown"}}})(),(window.CKEditor5=window.CKEditor5||{}).markdownGfm=r})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-markdown-gfm",
3
- "version": "35.4.0",
3
+ "version": "36.0.1",
4
4
  "description": "GitHub Flavored Markdown data processor for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,21 +12,23 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "^35.4.0",
15
+ "ckeditor5": "^36.0.1",
16
16
  "marked": "4.0.12",
17
17
  "turndown": "^6.0.0",
18
18
  "turndown-plugin-gfm": "^1.0.2"
19
19
  },
20
20
  "devDependencies": {
21
- "@ckeditor/ckeditor5-basic-styles": "^35.4.0",
22
- "@ckeditor/ckeditor5-code-block": "^35.4.0",
23
- "@ckeditor/ckeditor5-core": "^35.4.0",
24
- "@ckeditor/ckeditor5-dev-utils": "^31.0.0",
25
- "@ckeditor/ckeditor5-editor-classic": "^35.4.0",
26
- "@ckeditor/ckeditor5-engine": "^35.4.0",
27
- "@ckeditor/ckeditor5-list": "^35.4.0",
28
- "@ckeditor/ckeditor5-table": "^35.4.0",
29
- "@ckeditor/ckeditor5-theme-lark": "^35.4.0",
21
+ "@ckeditor/ckeditor5-basic-styles": "^36.0.1",
22
+ "@ckeditor/ckeditor5-code-block": "^36.0.1",
23
+ "@ckeditor/ckeditor5-core": "^36.0.1",
24
+ "@ckeditor/ckeditor5-dev-utils": "^32.0.0",
25
+ "@ckeditor/ckeditor5-editor-classic": "^36.0.1",
26
+ "@ckeditor/ckeditor5-engine": "^36.0.1",
27
+ "@ckeditor/ckeditor5-list": "^36.0.1",
28
+ "@ckeditor/ckeditor5-table": "^36.0.1",
29
+ "@ckeditor/ckeditor5-theme-lark": "^36.0.1",
30
+ "@types/marked": "^4.0.8",
31
+ "typescript": "^4.8.4",
30
32
  "webpack": "^5.58.1",
31
33
  "webpack-cli": "^4.9.0"
32
34
  },
@@ -45,7 +47,8 @@
45
47
  },
46
48
  "files": [
47
49
  "lang",
48
- "src",
50
+ "src/**/*.js",
51
+ "src/**/*.d.ts",
49
52
  "theme",
50
53
  "build",
51
54
  "ckeditor5-metadata.json",
@@ -58,6 +61,8 @@
58
61
  "block-elements"
59
62
  ],
60
63
  "scripts": {
64
+ "build": "tsc -p ./tsconfig.release.json",
65
+ "postversion": "npm run build",
61
66
  "dll:build": "webpack"
62
67
  }
63
68
  }
@@ -1,92 +1,72 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module markdown-gfm/gfmdataprocessor
8
7
  */
9
-
10
8
  import { HtmlDataProcessor } from 'ckeditor5/src/engine';
11
-
12
9
  import markdown2html from './markdown2html/markdown2html';
13
10
  import html2markdown, { turndownService } from './html2markdown/html2markdown';
14
-
15
11
  /**
16
12
  * This data processor implementation uses GitHub Flavored Markdown as input/output data.
17
13
  *
18
14
  * See the {@glink features/markdown Markdown output} guide to learn more on how to enable it.
19
- *
20
- * @implements module:engine/dataprocessor/dataprocessor~DataProcessor
21
15
  */
22
16
  export default class GFMDataProcessor {
23
- /**
24
- * Creates a new instance of the Markdown data processor class.
25
- *
26
- * @param {module:engine/view/document~Document} document
27
- */
28
- constructor( document ) {
29
- /**
30
- * HTML data processor used to process HTML produced by the Markdown-to-HTML converter and the other way.
31
- *
32
- * @private
33
- * @member {module:engine/dataprocessor/htmldataprocessor~HtmlDataProcessor}
34
- */
35
- this._htmlDP = new HtmlDataProcessor( document );
36
- }
37
-
38
- /**
39
- * Keeps the specified element in the output as HTML. This is useful if the editor contains
40
- * features producing HTML that is not a part of the Markdown standard.
41
- *
42
- * By default, all HTML tags are removed.
43
- *
44
- * @param element {String} The element name to be kept.
45
- */
46
- keepHtml( element ) {
47
- turndownService.keep( [ element ] );
48
- }
49
-
50
- /**
51
- * Converts the provided Markdown string to a view tree.
52
- *
53
- * @param {String} data A Markdown string.
54
- * @returns {module:engine/view/documentfragment~DocumentFragment} The converted view element.
55
- */
56
- toView( data ) {
57
- const html = markdown2html( data );
58
- return this._htmlDP.toView( html );
59
- }
60
-
61
- /**
62
- * Converts the provided {@link module:engine/view/documentfragment~DocumentFragment} to data format &mdash; in this
63
- * case to a Markdown string.
64
- *
65
- * @param {module:engine/view/documentfragment~DocumentFragment} viewFragment
66
- * @returns {String} Markdown string.
67
- */
68
- toData( viewFragment ) {
69
- const html = this._htmlDP.toData( viewFragment );
70
- return html2markdown( html );
71
- }
72
-
73
- /**
74
- * Registers a {@link module:engine/view/matcher~MatcherPattern} for view elements whose content should be treated as raw data
75
- * and not processed during the conversion from Markdown to view elements.
76
- *
77
- * The raw data can be later accessed by a
78
- * {@link module:engine/view/element~Element#getCustomProperty custom property of a view element} called `"$rawContent"`.
79
- *
80
- * @param {module:engine/view/matcher~MatcherPattern} pattern The pattern matching all view elements whose content should
81
- * be treated as raw data.
82
- */
83
- registerRawContentMatcher( pattern ) {
84
- this._htmlDP.registerRawContentMatcher( pattern );
85
- }
86
-
87
- /**
88
- * This method does not have any effect on the data processor result. It exists for compatibility with the
89
- * {@link module:engine/dataprocessor/dataprocessor~DataProcessor `DataProcessor` interface}.
90
- */
91
- useFillerType() {}
17
+ /**
18
+ * Creates a new instance of the Markdown data processor class.
19
+ */
20
+ constructor(document) {
21
+ this._htmlDP = new HtmlDataProcessor(document);
22
+ }
23
+ /**
24
+ * Keeps the specified element in the output as HTML. This is useful if the editor contains
25
+ * features producing HTML that is not a part of the Markdown standard.
26
+ *
27
+ * By default, all HTML tags are removed.
28
+ *
29
+ * @param element The element name to be kept.
30
+ */
31
+ keepHtml(element) {
32
+ turndownService.keep([element]);
33
+ }
34
+ /**
35
+ * Converts the provided Markdown string to a view tree.
36
+ *
37
+ * @param data A Markdown string.
38
+ * @returns The converted view element.
39
+ */
40
+ toView(data) {
41
+ const html = markdown2html(data);
42
+ return this._htmlDP.toView(html);
43
+ }
44
+ /**
45
+ * Converts the provided {@link module:engine/view/documentfragment~DocumentFragment} to data format &mdash; in this
46
+ * case to a Markdown string.
47
+ *
48
+ * @returns Markdown string.
49
+ */
50
+ toData(viewFragment) {
51
+ const html = this._htmlDP.toData(viewFragment);
52
+ return html2markdown(html);
53
+ }
54
+ /**
55
+ * Registers a {@link module:engine/view/matcher~MatcherPattern} for view elements whose content should be treated as raw data
56
+ * and not processed during the conversion from Markdown to view elements.
57
+ *
58
+ * The raw data can be later accessed by a
59
+ * {@link module:engine/view/element~Element#getCustomProperty custom property of a view element} called `"$rawContent"`.
60
+ *
61
+ * @param pattern The pattern matching all view elements whose content should
62
+ * be treated as raw data.
63
+ */
64
+ registerRawContentMatcher(pattern) {
65
+ this._htmlDP.registerRawContentMatcher(pattern);
66
+ }
67
+ /**
68
+ * This method does not have any effect on the data processor result. It exists for compatibility with the
69
+ * {@link module:engine/dataprocessor/dataprocessor~DataProcessor `DataProcessor` interface}.
70
+ */
71
+ useFillerType() { }
92
72
  }
@@ -1,153 +1,126 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module markdown-gfm/html2markdown
8
7
  */
9
-
8
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
9
+ // Importing types for this package is problematic, so it's omitted.
10
+ // @ts-ignore
10
11
  import TurndownService from 'turndown';
12
+ // There no avaialble types for 'turndown-plugin-gfm' module and it's not worth to generate them on our own.
13
+ // @ts-ignore
11
14
  import { gfm } from 'turndown-plugin-gfm';
12
-
13
15
  // Override the original escape method by not escaping links.
14
16
  const originalEscape = TurndownService.prototype.escape;
15
-
16
- function escape( string ) {
17
- string = originalEscape( string );
18
-
19
- // Escape "<".
20
- string = string.replace( /</g, '\\<' );
21
-
22
- return string;
17
+ function escape(string) {
18
+ string = originalEscape(string);
19
+ // Escape "<".
20
+ string = string.replace(/</g, '\\<');
21
+ return string;
23
22
  }
24
-
25
- TurndownService.prototype.escape = function( string ) {
26
- // Urls should not be escaped. Our strategy is using a regex to find them and escape everything
27
- // which is out of the matches parts.
28
-
29
- let escaped = '';
30
- let lastLinkEnd = 0;
31
-
32
- for ( const match of matchAutolink( string ) ) {
33
- const index = match.index;
34
-
35
- // Append the substring between the last match and the current one (if anything).
36
- if ( index > lastLinkEnd ) {
37
- escaped += escape( string.substring( lastLinkEnd, index ) );
38
- }
39
-
40
- const matchedURL = match[ 0 ];
41
-
42
- escaped += matchedURL;
43
-
44
- lastLinkEnd = index + matchedURL.length;
45
- }
46
-
47
- // Add text after the last link or at the string start if no matches.
48
- if ( lastLinkEnd < string.length ) {
49
- escaped += escape( string.substring( lastLinkEnd, string.length ) );
50
- }
51
-
52
- return escaped;
23
+ TurndownService.prototype.escape = function (string) {
24
+ // Urls should not be escaped. Our strategy is using a regex to find them and escape everything
25
+ // which is out of the matches parts.
26
+ let escaped = '';
27
+ let lastLinkEnd = 0;
28
+ for (const match of matchAutolink(string)) {
29
+ const index = match.index;
30
+ // Append the substring between the last match and the current one (if anything).
31
+ if (index > lastLinkEnd) {
32
+ escaped += escape(string.substring(lastLinkEnd, index));
33
+ }
34
+ const matchedURL = match[0];
35
+ escaped += matchedURL;
36
+ lastLinkEnd = index + matchedURL.length;
37
+ }
38
+ // Add text after the last link or at the string start if no matches.
39
+ if (lastLinkEnd < string.length) {
40
+ escaped += escape(string.substring(lastLinkEnd, string.length));
41
+ }
42
+ return escaped;
53
43
  };
54
-
55
- const turndownService = new TurndownService( {
56
- codeBlockStyle: 'fenced',
57
- hr: '---',
58
- headingStyle: 'atx'
59
- } );
60
-
61
- turndownService.use( [
62
- gfm,
63
- todoList
64
- ] );
65
-
44
+ const turndownService = new TurndownService({
45
+ codeBlockStyle: 'fenced',
46
+ hr: '---',
47
+ headingStyle: 'atx'
48
+ });
49
+ turndownService.use([
50
+ gfm,
51
+ todoList
52
+ ]);
66
53
  /**
67
54
  * Parses HTML to a markdown.
68
- *
69
- * @param {String} html
70
- * @returns {String}
71
55
  */
72
- export default function html2markdown( html ) {
73
- return turndownService.turndown( html );
56
+ export default function html2markdown(html) {
57
+ return turndownService.turndown(html);
74
58
  }
75
-
76
59
  export { turndownService };
77
-
78
60
  // This is a copy of the original taskListItems rule from turdown-plugin-gfm, with minor changes.
79
- function todoList( turndownService ) {
80
- turndownService.addRule( 'taskListItems', {
81
- filter( node ) {
82
- return node.type === 'checkbox' &&
83
- // Changes here as CKEditor outputs a deeper structure.
84
- ( node.parentNode.nodeName === 'LI' || node.parentNode.parentNode.nodeName === 'LI' );
85
- },
86
- replacement( content, node ) {
87
- return ( node.checked ? '[x]' : '[ ]' ) + ' ';
88
- }
89
- } );
61
+ function todoList(turndownService) {
62
+ turndownService.addRule('taskListItems', {
63
+ filter(node) {
64
+ return node.type === 'checkbox' &&
65
+ // Changes here as CKEditor outputs a deeper structure.
66
+ (node.parentNode.nodeName === 'LI' || node.parentNode.parentNode.nodeName === 'LI');
67
+ },
68
+ replacement(content, node) {
69
+ return (node.checked ? '[x]' : '[ ]') + ' ';
70
+ }
71
+ });
90
72
  }
91
-
92
73
  // Autolink matcher.
93
74
  const regex = new RegExp(
94
- // Prefix.
95
- /\b(?:(?:https?|ftp):\/\/|www\.)/.source +
96
-
97
- // Domain name.
98
- /(?![-_])(?:[-_a-z0-9\u00a1-\uffff]{1,63}\.)+(?:[a-z\u00a1-\uffff]{2,63})/.source +
99
-
100
- // The rest.
101
- /(?:[^\s<>]*)/.source,
102
- 'gi'
103
- );
104
-
105
- // Trimming end of link.
106
- // https://github.github.com/gfm/#autolinks-extension-
107
- function* matchAutolink( string ) {
108
- for ( const match of string.matchAll( regex ) ) {
109
- const matched = match[ 0 ];
110
- const length = autolinkFindEnd( matched );
111
-
112
- yield Object.assign(
113
- [ matched.substring( 0, length ) ],
114
- { index: match.index }
115
- );
116
-
117
- // We could adjust regex.lastIndex but it's not needed because what we skipped is for sure not a valid URL.
118
- }
75
+ // Prefix.
76
+ /\b(?:(?:https?|ftp):\/\/|www\.)/.source +
77
+ // Domain name.
78
+ /(?![-_])(?:[-_a-z0-9\u00a1-\uffff]{1,63}\.)+(?:[a-z\u00a1-\uffff]{2,63})/.source +
79
+ // The rest.
80
+ /(?:[^\s<>]*)/.source, 'gi');
81
+ /**
82
+ * Trimming end of link.
83
+ * https://github.github.com/gfm/#autolinks-extension-
84
+ */
85
+ function* matchAutolink(string) {
86
+ for (const match of string.matchAll(regex)) {
87
+ const matched = match[0];
88
+ const length = autolinkFindEnd(matched);
89
+ yield Object.assign([matched.substring(0, length)], { index: match.index });
90
+ // We could adjust regex.lastIndex but it's not needed because what we skipped is for sure not a valid URL.
91
+ }
119
92
  }
120
-
121
- // Returns the new length of the link (after it would trim trailing characters).
122
- function autolinkFindEnd( string ) {
123
- let length = string.length;
124
-
125
- while ( length > 0 ) {
126
- const char = string[ length - 1 ];
127
-
128
- if ( '?!.,:*_~\'"'.includes( char ) ) {
129
- length--;
130
- } else if ( char == ')' ) {
131
- let openBrackets = 0;
132
-
133
- for ( let i = 0; i < length; i++ ) {
134
- if ( string[ i ] == '(' ) {
135
- openBrackets++;
136
- } else if ( string[ i ] == ')' ) {
137
- openBrackets--;
138
- }
139
- }
140
-
141
- // If there is fewer opening brackets then closing ones we should remove a closing bracket.
142
- if ( openBrackets < 0 ) {
143
- length--;
144
- } else {
145
- break;
146
- }
147
- } else {
148
- break;
149
- }
150
- }
151
-
152
- return length;
93
+ /**
94
+ * Returns the new length of the link (after it would trim trailing characters).
95
+ */
96
+ function autolinkFindEnd(string) {
97
+ let length = string.length;
98
+ while (length > 0) {
99
+ const char = string[length - 1];
100
+ if ('?!.,:*_~\'"'.includes(char)) {
101
+ length--;
102
+ }
103
+ else if (char == ')') {
104
+ let openBrackets = 0;
105
+ for (let i = 0; i < length; i++) {
106
+ if (string[i] == '(') {
107
+ openBrackets++;
108
+ }
109
+ else if (string[i] == ')') {
110
+ openBrackets--;
111
+ }
112
+ }
113
+ // If there is fewer opening brackets then closing ones we should remove a closing bracket.
114
+ if (openBrackets < 0) {
115
+ length--;
116
+ }
117
+ else {
118
+ break;
119
+ }
120
+ }
121
+ else {
122
+ break;
123
+ }
124
+ }
125
+ return length;
153
126
  }
package/src/index.js CHANGED
@@ -1,11 +1,8 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module markdown-gfm
8
7
  */
9
-
10
8
  export { default as Markdown } from './markdown';
11
-
package/src/markdown.js CHANGED
@@ -1,36 +1,29 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module markdown-gfm/markdown
8
7
  */
9
-
10
8
  import { Plugin } from 'ckeditor5/src/core';
11
9
  import GFMDataProcessor from './gfmdataprocessor';
12
-
13
10
  /**
14
11
  * The GitHub Flavored Markdown (GFM) plugin.
15
12
  *
16
13
  * For a detailed overview, check the {@glink features/markdown Markdown feature documentation}.
17
- *
18
- * @extends module:core/plugin~Plugin
19
14
  */
20
15
  export default class Markdown extends Plugin {
21
- /**
22
- * @inheritDoc
23
- */
24
- constructor( editor ) {
25
- super( editor );
26
-
27
- editor.data.processor = new GFMDataProcessor( editor.data.viewDocument );
28
- }
29
-
30
- /**
31
- * @inheritDoc
32
- */
33
- static get pluginName() {
34
- return 'Markdown';
35
- }
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ constructor(editor) {
20
+ super(editor);
21
+ editor.data.processor = new GFMDataProcessor(editor.data.viewDocument);
22
+ }
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName() {
27
+ return 'Markdown';
28
+ }
36
29
  }
@@ -1,52 +1,44 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module markdown-gfm/markdown2html
8
7
  */
9
-
10
8
  import { marked } from 'marked';
11
-
12
9
  // Overrides.
13
- marked.use( {
14
- tokenizer: {
15
- // Disable the autolink rule in the lexer.
16
- autolink: () => null,
17
- url: () => null
18
- },
19
- renderer: {
20
- checkbox( ...args ) {
21
- // Remove bogus space after <input type="checkbox"> because it would be preserved
22
- // by DomConverter as it's next to an inline object.
23
- return Object.getPrototypeOf( this ).checkbox.call( this, ...args ).trimRight();
24
- },
25
-
26
- code( ...args ) {
27
- // Since marked v1.2.8, every <code> gets a trailing "\n" whether it originally
28
- // ended with one or not (see https://github.com/markedjs/marked/issues/1884 to learn why).
29
- // This results in a redundant soft break in the model when loaded into the editor, which
30
- // is best prevented at this stage. See https://github.com/ckeditor/ckeditor5/issues/11124.
31
- return Object.getPrototypeOf( this ).code.call( this, ...args ).replace( '\n</code>', '</code>' );
32
- }
33
- }
34
- } );
35
-
10
+ marked.use({
11
+ tokenizer: {
12
+ // Disable the autolink rule in the lexer.
13
+ autolink: () => null,
14
+ url: () => null
15
+ },
16
+ renderer: {
17
+ checkbox(...args) {
18
+ // Remove bogus space after <input type="checkbox"> because it would be preserved
19
+ // by DomConverter as it's next to an inline object.
20
+ return Object.getPrototypeOf(this).checkbox.call(this, ...args).trimRight();
21
+ },
22
+ code(...args) {
23
+ // Since marked v1.2.8, every <code> gets a trailing "\n" whether it originally
24
+ // ended with one or not (see https://github.com/markedjs/marked/issues/1884 to learn why).
25
+ // This results in a redundant soft break in the model when loaded into the editor, which
26
+ // is best prevented at this stage. See https://github.com/ckeditor/ckeditor5/issues/11124.
27
+ return Object.getPrototypeOf(this).code.call(this, ...args).replace('\n</code>', '</code>');
28
+ }
29
+ }
30
+ });
36
31
  /**
37
32
  * Parses markdown string to an HTML.
38
- *
39
- * @param {String} markdown
40
- * @returns {String}
41
33
  */
42
- export default function markdown2html( markdown ) {
43
- return marked.parse( markdown, {
44
- gfm: true,
45
- breaks: true,
46
- tables: true,
47
- xhtml: true,
48
- headerIds: false
49
- } );
34
+ export default function markdown2html(markdown) {
35
+ const options = {
36
+ gfm: true,
37
+ breaks: true,
38
+ tables: true,
39
+ xhtml: true,
40
+ headerIds: false
41
+ };
42
+ return marked.parse(markdown, options);
50
43
  }
51
-
52
44
  export { marked };